﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["goods"] = new List<string>();
            }
            if (Session["name"] == null)
            {
                Response.Redirect("WebForm2.aspx");
            }
            else
            {
                Literal1.Text = "欢迎你，" + Session["name"] + "!";
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            List<string> list = (List<string>)Session["goods"];
            foreach (Control item in form1.Controls)
            {
                if (item is CheckBox)
                {
                    CheckBox cb = (CheckBox)item;
                    if (cb.Checked)
                    {
                        list.Add(cb.Text);
                    }
                }
            }
            Button1.Text = "添加成功";
            Response.Write(Session.SessionID);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("WebForm3.aspx");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("WebForm1.aspx");
        }
    }
}